# @Time : 2020/8/28 14:42
# @Author : Fioman 
# @Phone : 13149920693
"""
轮廓的查找和绘制
"""
import cv2 as cv
import imutils

image = cv.imread("pic/17.png")
gray = cv.cvtColor(image, cv.COLOR_BGR2GRAY)
cv.imshow("Original", gray)

cnts = cv.findContours(gray, cv.RETR_LIST, cv.CHAIN_APPROX_SIMPLE)
cnts = imutils.grab_contours(cnts)
cntsSorted = sorted(cnts,key=cv.contourArea,reverse=True)
clone = image.copy()
cv.drawContours(clone, cntsSorted[:4], -1, (0, 255, 0), 2)
cv.imshow("Contours", clone)
cv.waitKey(0)
